package com.nmgsr.ptmsapp.adapter;

import static com.nmgsr.ptmsapp.utils.ContantConfig.Base_URL;

import android.annotation.SuppressLint;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.nmgsr.beans.responsedao.PtmsVideoCaptureRes;
import com.nmgsr.beans.responsedao.PtmsWarnTestRes;
import com.nmgsr.ptmsapp.R;
import com.nmgsr.ptmsapp.utils.DateUtils;
import com.squareup.picasso.Picasso;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class ListPtmsVideoCaptureAdapter extends BaseQuickAdapter<PtmsVideoCaptureRes, BaseViewHolder> {
    public ListPtmsVideoCaptureAdapter() {
        super(R.layout.list_ptms_video_capture_item);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PtmsVideoCaptureRes list) {
        baseViewHolder.setText(R.id.tv_camera_no, String.valueOf(list.getCameraId()));
        try {
            String formattedScrapDate = DateUtils.formatDate(list.getCaptureTime(), "yyyy-MM-dd HH:mm:ss", "yyyy年MM月dd日 HH:mm:ss");
            baseViewHolder.setText(R.id.tvTime,formattedScrapDate);

        } catch (Exception e) {
            // 如果你字段可能为空，可以统一处理异常或默认值
            baseViewHolder.setText(R.id.tv_recordTime, "日期格式错误");
        }
        baseViewHolder.setText(R.id.tv_camera_name, String.valueOf(list.getCameraNo()));
        ImageView imgHead = baseViewHolder.findView(R.id.imgHead);
        String imgUrl = Base_URL+list.getCapturePath();
        Picasso.get().load(imgUrl).placeholder(R.drawable.error_data).error(R.drawable.error_data).into(imgHead);
    }
}
